#!/bin/bash

#------------------Create Data------------------
echo "
# loop names	Original    Split+Block	
Accu          21331.23    11996.15175	
Edegcon       34700.64    18029.203		
Vflux         45232.09    26940.4099	
Iflux         12234.96    5316.249
Wfflux        978.04      480.666975
Sumwalls      228.34      92.6185475
"> data1




#--------------------------Plot Data----------------------------

gnuplot <<END
reset
set grid xtics ytics mxtics mytics 
set term epslatex color 
set size 1,0.85


#set format "$%g$"
#set format xy "$%g$"

set xlabel " " 
set ylabel "Runtime (mili-seconds)"3,2

#set xrange [0:1024]
#set yrange [1:1000]

set style line 1 lt -1 lw 0.3
set key width -2.7
set key box linestyle 1 outside top

set key horiz
#set log x 2
#set log y 2
set border lw 2

set output "./Fig.tex"

set auto x
set style data histogram



set style histogram cluster gap 2 
set style fill solid 1 border -1 
set boxwidth  1.0

set xtic rotate by 0
#set boxwidth 20 relative

plot 'data1' using 2:xtic(1) linecolor rgb '#880000' ti "Original",\
     		      '' u 3 fill pattern 1 linecolor rgb '#006600' ti "Split";
END

#
#,\
#   		      '' u 6 fill pattern 2 linecolor rgb '#800080' ti "Split+Color",\
#		      '' u 7 fill pattern 3 linecolor rgb '#800080' ti "Split+BLock",\
#		      '' u 8 fill pattern 4 linecolor rgb '#800080' ti "Split+Block+Color";

#-----------------------------------------

epstopdf Fig.eps

#-----------------------------------------
echo " \documentclass{article}
\usepackage{graphics}
\usepackage{nopageno}
%\usepackage{mathpazo}
\usepackage{txfonts}
\usepackage[usenames]{color}
	
\begin{document}
	
\begin{center}
  \normalsize{
  \input{./Fig.tex}}
\end{center}
	
\end{document}" > Figure.tex
#-----------------------------------------

pdflatex Figure.tex
pdfcrop Figure.pdf

mv Figure-crop.pdf CUDA.pdf

rm -f data* Figure.tex Figure.pdf Figure.log Figure.aux Figure.log Fig.eps Fig.tex Fig.pdf *~
